package reflect;

import java.lang.reflect.Field;

public class ReflectDemo8 {
    public static void main(String[] args) throws Exception {
        Teacher t = new Teacher();
//        t.name = "张三";

        Class<?> cls = Class.forName("reflect.Teacher");
        Object obj = cls.newInstance();

        Field f = cls.getDeclaredField("name");
        f.setAccessible(true);
        f.set(obj, "张三");
        System.out.println(obj);
        System.out.println(f.get(obj));
        f.setAccessible(false);
    }
}
